<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>get请求</button>
    <button>post请求</button>
    <p></p>

    <script src="./ajax.js"></script>
    <script>

        let requestHead = 'http://localhost:8888';

        const oBtn = document.querySelectorAll('button');
        const oP = document.querySelector('p');

        oBtn[0].addEventListener('click',function(){
            ajaxRequest(`${requestHead}/test/third`,'get','name=张三&age=19',function(result){
                oP.innerHTML = result;
                console.log(JSON.parse(result));
            });
        })

        oBtn[1].addEventListener('click',function(){
            ajaxRequest(`${requestHead}/test/fourth`,'post','name=张三&age=18',function(result){
                oP.innerHTML = result;
                console.log(JSON.parse(result));
            });
        })

    </script>
</body>
</html>